import {
  HomeOutlined, IdcardOutlined, PicRightOutlined, ShopOutlined, TeamOutlined,
} from '@ant-design/icons';
import React from 'react';

interface IRoute {
  path:string;
  name:string;
  icon?:React.ReactNode;
  hideInMenu?:boolean;
}

export const ROUTE_KEY = {
  HOME: 'home',
  MY: 'my',
  ORG: 'org',
  No_Org: 'noOrg',
  STUDENT: 'student',
  COURSE: 'course',
  PRODUCT: 'product',
  TEACHER: 'teacher',
  PAGE_404: 'p404',
};

// Record<string, IRoute> Record代表对象 string代表键类型 IRoute代表值类型
export const ROUTE_CONFIG:Record<string, IRoute> = {
  [ROUTE_KEY.HOME]: {
    path: '/',
    name: '首页',
    hideInMenu: true,
    icon: <HomeOutlined />,
  },
  [ROUTE_KEY.MY]: {
    path: 'my',
    name: '个人信息',
    hideInMenu: true,
    icon: <HomeOutlined />,
  },
  [ROUTE_KEY.STUDENT]: {
    path: 'student',
    name: '学员管理',
    icon: <TeamOutlined />,
  },
  [ROUTE_KEY.COURSE]: {
    path: 'course',
    name: '课程管理',
    icon: <PicRightOutlined />,
  },
  [ROUTE_KEY.PRODUCT]: {
    path: 'product',
    name: '商品管理',
    icon: <TeamOutlined />,
  },
  [ROUTE_KEY.TEACHER]: {
    path: 'teacher',
    name: '教师管理',
    icon: <IdcardOutlined />,
  },
  [ROUTE_KEY.ORG]: {
    path: 'org',
    name: '门店管理',
    hideInMenu: true,
    icon: <ShopOutlined />,
  },

  [ROUTE_KEY.No_Org]: {
    path: 'noOrg',
    name: '选择门店提示',
    hideInMenu: true,
  },
  [ROUTE_KEY.PAGE_404]: {
    path: '*',
    hideInMenu: true,
    name: '404',
  },
};

// 这个routes是给main.tsx里的路由使用的
export const routes = Object.keys(ROUTE_CONFIG).map(((key) => ({ ...ROUTE_CONFIG[key], key })));

export const getRouteByKey = (key:string) => ROUTE_CONFIG[key];
